<template>
	<scroll-view scroll-y="true" class="container" @scrolltolower='lower' refresher-enabled refresher-threshold="45" :refresher-triggered="refresherTriggered" @refresherrefresh='refresherrefresh'>
		<evaluateItem v-if="list.length!=0" :list="list"></evaluateItem>
		<loadMore v-else :status="'empty'" :text="'暂时还没有服务评价'" />
	</scroll-view>
</template>

<script setup lang="ts">
import evaluateItem from '../components/evaluate-item/index.vue'
import { ref } from 'vue'
import { onLoad,onReachBottom} from '@dcloudio/uni-app'
import api from '@/api'
const url = ref<string>('https://xjs-oss-prod.oss-cn-shenzhen.aliyuncs.com/xjs-static/')
onLoad(async (e) => {
	studioId.value = e.studioId
	userId.value = e.userId?e.userId:''
	await getDetails()
})
const studioId = ref<number>(0)  //工作室id
const userId = ref<string>('')//陪宠师id
const page = ref<number>(1)
const flay = ref<boolean>(true)
const list = ref<listType[]>([])
	
//获取详情
const getDetails = async() =>{
	let data = {
		page:page.value,
		limit:10,
		studioId:studioId.value,
	}
	if(userId.value){
		data.petsitterUserId = userId.value
	}
	const res:any = await api({
		method: 'get',
		url: `/mall/order/assess/page`,
		data:data
	})
	if(res){
		list.value = page.value==1? res.data.records:list.value.concat(res.data.records)
		flay.value = list.value.length>=res.data.total?false:true
	}
}
	
const refresherTriggered = ref<boolean>(false)
//下拉刷新
const refresherrefresh = () =>{
	refresherTriggered.value = true
	page.value = 1
	getDetails()
	setTimeout(()=>{
		refresherTriggered.value = false
	},2000)
}
//滚动到底事件
const lower = () =>{
	if(!flay.value) return
	page.value++
	getDetails()
}
interface listType {
	id:number
	title:string
	coverPic:string
	userAvatar:string
	userNickName:string
}
</script>

<style lang="scss" scoped>
.container{
	line-height: 1;
	width: 100vw;
	height: 100vh;
	padding:24rpx 32rpx;
	box-sizing: border-box;
	background-color: #F9F6F6;
	
}
</style>